分散式協作將重點從單一中央資料夾轉移至一個生態系統,包含 獨立且點對點的倉儲。在此模型中,每個倉儲——例如 my-git-repo 和 marys-repo——都是完整的宇宙,各自擁有獨立的歷史與分支資料。
1. 定義「遠端」
簡單來說,一個 遠端倉儲 是屬於別人的倉儲。它可以存在於公司的網路、網際網路(GitHub),甚至只是你本機檔案系統中的另一個資料夾。其關鍵特徵在於,它是獨立運作的實例,工作內容發生在你直接控制範圍之外。
2. 遠端作為書籤
技術上來說,遠端只是一個 簡寫別名 或「書籤」。無需每次輸入 /Users/Mary/projects/marys-repo 來查看她的進度,你可以將該路徑對應到一個簡單的名稱,例如 mary。
3. 狀態的獨立性
倉儲之間是 連結但不自動同步 。建立遠端書籤不會移動程式碼;它僅建立未來透過推送或取得進行資料交換的 路徑 ,以供未來透過推送或取得進行資料交換。
main.py
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
QUESTION 1
In the context of Git, what is the defining characteristic of a 'remote' repository?
It must be hosted on a cloud provider like GitHub.
It is any repository that is distinct from your current project directory.
It is a central master repository that controls all other clones.
It is a repository that is read-only.
✅ Correct!
Correct! A remote is simply any repository that is not your own, whether it's on a server, a network drive, or another folder on your computer.❌ Incorrect
A remote doesn't have to be 'central' or 'on the cloud.' It just needs to be a separate Git instance.QUESTION 2
What is the primary technical purpose of a 'Remote' in the Git configuration?
To compress the history of a project.
To act as a bookmark for a full path to another repository.
To automatically synchronize local changes with a server.
To encrypt the connection between two developers.
✅ Correct!
Yes. Remotes are aliases (bookmarks) that map human-readable names to physical file paths or network URLs.❌ Incorrect
Git never synchronizes automatically. Remotes just store the location where you *can* manually sync.QUESTION 3
If you clone 'Repo-A' into a new folder 'Repo-B', what does Git typically name the remote bookmark pointing back to 'Repo-A'?
master
upstream
origin
parent
✅ Correct!
Upon cloning, Git automatically creates a remote bookmark named 'origin' pointing to the source repository.❌ Incorrect
While you can rename it, 'origin' is the universal default bookmark created during a clone.QUESTION 4
True or False: A remote repository can exist on the same physical hard drive as your local repository.
True
False
✅ Correct!
True. Remotes can point to file URLs (e.g., ../other-folder), not just internet addresses.❌ Incorrect
Git is location-agnostic; as long as it's a valid path to another .git directory, it can be a remote.QUESTION 5
Which command is used to view the physical URLs associated with your remote bookmarks?
git remote -v
git remote --show
git list --remotes
git remote connect
✅ Correct!
The -v (verbose) flag shows both the alias and the underlying fetch/push paths.❌ Incorrect
Plain 'git remote' only shows the names. You need the verbose flag to see the actual paths.Establishing a Peer Connection
Scenario: Local Collaboration Setup
You are working in 'my-git-repo'. Your colleague, Mary, has her repository in a sibling folder named 'marys-repo'. You need to establish a connection to her work so you can eventually pull her updates.
Q
What is the command to create a remote bookmark named 'mary' that points to her repository located at '../marys-repo'?
Solution:
git remote add mary ../marys-repoQ
After adding the remote, why are Mary's new commits not immediately visible in your 'master' branch history?
Solution:
Because every repository has an Independence of State. Adding a remote only maps the connection; you must explicitly perform a
Because every repository has an Independence of State. Adding a remote only maps the connection; you must explicitly perform a
fetch or pull to actually transfer data between the entities.